<?php
/**
 * User: Tony Chen
 * Date: 2017/7/23.
 */

define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT']);
include ROOT_PATH . '/utils/function.php';

$post = $_POST;

$sql = sprintf("SELECT username, password FROM user WHERE username = '%s'", $post['username']);
$ret = newMysql()->select($sql);


if ($ret === false) {
    exit('用户名不存在');
}

$ret = $ret[0];
//
//var_dump($ret);
//var_dump($post);
//var_dump(md5($post['username']));
//var_dump($post['username'] === $ret['username']);
//var_dump(md5($post['password']) === $ret['password']);
//exit();

if ($post['username'] === $ret['username'] && md5($post['password']) === $ret['password']) {
    echo '登陆成功';

    sessionSet('isLogin', true);
    exit();
}

echo '登陆失败';